package com.xingkeduo.business.user.service;

import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.CraftsmanLevelQO;
import com.xingkeduo.pojo.query.CraftsmanLoginHistoryQO;
import com.xingkeduo.pojo.table.CraftsmanLevelTO;
import com.xingkeduo.pojo.table.CraftsmanLoginHistoryTO;
import com.xingkeduo.util.pojo.exception.DataException;
import com.xingkeduo.util.tool.CommonUtil;
import com.xingkeduo.util.tool.IdentityUtil;
import com.xingkeduo.util.tool.IdentityUtil.Worker;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/3/18 15:05
 **/
@Component
public class CraftsmanLoginHistoryService {
    private static final String NAMESPACE = CommonUtil.formatNamespace(CraftsmanLoginHistoryTO.class);
    @Resource(name = "mysqlUserMasterDao")
    private DatabaseAccessObject<CraftsmanLoginHistoryTO, CraftsmanLoginHistoryQO> dao;


    /**新增登录历史
     * @param craftsmanLoginHistoryTO:
     * @return : void
     * @author : gaozifeng
     * @date : 2019/3/18 21:35
     */
    public void insert(CraftsmanLoginHistoryTO craftsmanLoginHistoryTO) throws Throwable {
        craftsmanLoginHistoryTO.initId(IdentityUtil.nextId(Worker.USER)).setUpdatedBy(craftsmanLoginHistoryTO.getCreatedBy());
        if (dao.insert(NAMESPACE, craftsmanLoginHistoryTO) < 1){
            throw new DataException(DataException.Type.FAIL, "考核结果");
        }
    }

}
